package com.ctsi.offlinesupport.app.rest;

import com.ctsi.framework.common.response.UnifiedResponse;
import com.ctsi.framework.security.util.SecurityUtil;
import com.ctsi.offlinesupport.service.FlowBackService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.nio.charset.Charset;

/**
 * @author: zhangjw
 * @Date: 2018/11/24 12:03
 * @Description:
 */
@RestController
public class SupportBackController {

    private static final Logger logger = LoggerFactory.getLogger(SupportBackController.class);



    @Autowired
    private FlowBackService flowBackService;

    @PostMapping(value = "/support/uni-back/{taskId}")
    public UnifiedResponse<Void> back(@PathVariable("taskId") String taskId, @RequestParam(value = "comment") String comment){
        String userId = SecurityUtil.getUser().getUserId();
        logger.warn("back of comment is {}",comment);
        logger.warn("default charset name is {}",Charset.defaultCharset().name());
        flowBackService.sendBack(taskId,userId,comment);
        return UnifiedResponse.ok();
    }

}
